<?php 

class suipaiController extends appController
{
	public function index()
	{
		$page = yf_empty(intval($_GET['page']), 1, true);
		$sort['c'] = yf_empty($_GET['c'], '', true);
		$sort['k'] = yf_empty($_GET['k'], '', true);
		
		
		$list = Model('suipai')->get_list($sort, $page);
		$this->assign('ad_list', $list['data']);
		$this->assign('user_list_page', $list['pagelink']);
// 		var_dump($list['data']);
		$this->display("index.html");
	}
	
	public function picture()
	{
		$page = yf_empty(intval($_GET['page']), 1, true);
		$sort['c'] = yf_empty($_GET['c'], '', true);
		$sort['k'] = yf_empty($_GET['k'], '', true);
	
	
		$list = Model('suipai')->get_pic_list($sort, $page);
		$this->assign('ad_list', $list['data']);
		$this->assign('user_list_page', $list['pagelink']);
		// 		var_dump($list['data']);
		$this->display("picture.html");
	}
	
	public function ordering()
	{
		$id = yf_empty(intval($_POST['id']), '', true);
		$val = yf_empty(intval($_POST['val']), '', true);
		$result = Model('suipai')->ordering($val, $id);
		$this->showMsg($result);
	}
	

	public function del()
	{
		$id=isset($_REQUEST['id'])?$_REQUEST['id']:'';
	
		if(is_array($id))
		{
			foreach($id as $k=>$v)
			{
				$result=Model('suipai')->del_sp($v,"suipai");
			}
		}
		else
		{
			$id=intval($id);
	
			$result=Model('suipai')->del_sp($id,"suipai");
		}
		print_r(json_encode($result));
	
	}
	
	public function del_pic()
	{
		$id=isset($_REQUEST['id'])?$_REQUEST['id']:'';
	
		if(is_array($id))
		{
			foreach($id as $k=>$v)
			{
				$result=Model('suipai')->del_pic($v);
			}
		}
		else
		{
			$id=intval($id);
	
			$result=Model('suipai')->del_pic($id);
		}
		print_r(json_encode($result));
	
	}
	
}

?>